<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>非受控组件</title>
</head>
<body>
  <!-- 准备容器 -->
  <div id="test"></div>
  <!-- 按照顺序引入 -->
  <script type="text/javascript" src="../../js/react.development.js"></script>
  <script type="text/javascript" src="../../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../../js/babel.min.js"></script>
  <script type="text/babel" >
    class Login extends React.Component {
        handler=(event)=>{
            event.preventDefault()  // 阻止表单提交
            const {username,password} =this // 现用现取
            alert(`用户名是${username.value},密码是${password.value}`)
        }
        render(){
            return (
                <form action="http://www.baidu.com" onSubmit={this.handler}>
                    用户名：<input ref={a=>this.username=a} type="text" />
                    密码：<input  ref={a=>this.password=a} type="password" />
                    <button>登录</button>
                </form>
            )
        }
    }
    ReactDOM.render(<Login/>,document.getElementById('test'))
  </script>
</body>
</html>